package org.bw.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * <p>
 *
 * </p>
 *
 * @author hy.wu
 * @since 2022-07-12
 */
@Getter
@Setter
@TableName("tb_movie")
@Document(indexName = "yk",type = "movie")
public class Movie implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @Field(type = FieldType.Keyword,name = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @NotBlank(message = "姓名非空")
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String name;

    @NotBlank(message = "概括非空")
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String contents;
    @NotNull(message = "上映时间非空")
    private Date created;
    private Integer tid;
    private String picture;

    //扩展字段
    @TableField(exist = false)
    private String tname;

    @TableField(exist = false)
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String dname;

    @TableField(exist = false)
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String aname;

    @TableField(exist = false)
    private String dids;
    @TableField(exist = false)
    private String aids;

    //日期区间
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @TableField(exist = false)
    private Date endTime;
    //关键字查询
    @TableField(exist = false)
    private String content;
    //添加的数组
    @TableField(exist = false)
    private Integer[] directIds;
    @TableField(exist = false)
    private Integer[] actorIds;
    //逻辑删除字段
    @TableLogic
    private Integer deleted;
}
